package com.wencai.util;

/**
 * @author wangpan
 * @date 2023/5/10
 */
public class DateConverter {
    public static String convertDate(String rawDate) {
        String pattern = "(\\d{4})(\\d{2})(\\d{2})";
        if (rawDate.matches(pattern)) {
            return rawDate.replaceAll(pattern, "$1-$2-$3");
        }
        return rawDate;
    }

    public static String convertToRaw(String date) {
        String pattern = "(\\d{4})-(\\d{2})-(\\d{2})";
        if (date.matches(pattern)) {
            return date.replaceAll(pattern, "$1$2$3");
        }
        return date;
    }
}
